﻿using System;
using System.Collections.Generic;

namespace Moonlite.Languages.Andromeda.Implementation
{
    internal abstract class AbstractCompilationErrors : ICompilationErrors
    {
        private List<ICompilationError> compilationErrors = new List<ICompilationError>();
        public List<ICompilationError> CompilationErrors
        {
            get
            {
                return compilationErrors;
            }
        }

        public int Count
        {
            get
            {
                return compilationErrors.Count;
            }
        }

        public abstract bool AddCompilationErrorCore(ICompilationError compilationError);
        public void AddCompilationError(ICompilationError compilationError)
        {
            if (AddCompilationErrorCore(compilationError))
            {
                compilationErrors.Add(compilationError);
            }
        }

        public AbstractCompilationErrors()
            : this(new List<ICompilationError>())
        {
        }

        public AbstractCompilationErrors(List<ICompilationError> compilationErrors)
        {
            this.compilationErrors = compilationErrors;
        }
    }
}
